$primary-color: #f3e1e1;
$main-bg-color: #f8faff;
$aside-width: 192px;
$aside-width-collapsed: 38px;
$theme-light-aside-color: #2e2e2e;
$theme-light-menu-hover-color: #eaf3fd;
$theme-dark-menu-hover-color: #202b3f;


@mixin mix-flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@mixin mix-ellipsis {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

* { margin: 0; padding: 0; box-sizing: border-box;}
html, body {
  height: 100%;
}
body {
  font-size: 14px;
  color: rgba(0,0,0,0.65);
}
ul, li {list-style: none;}
// 通用样式
.flex-space {
  flex: 1;
}


.layout-container {
  height: 100%;
  &.theme-dark { // 深色主题
    .layout-aside {
      background: #2a364c;
      color: #fff;
    }
  }
  &.theme-light { // 浅色主题
    .layout-aside {
      color: $theme-light-aside-color;
      .aside-header {
        .cur-selected-box {
          .cur-selected-inner {
            background: #f6f6f6;
            .right-arrow {
              &:after {
                border-left-color: $theme-light-aside-color;
              }
            }
          }
        }
      }
      .menus-wrapper {
        .menu-level-one { // 一级菜单
          .menu-name {
            &:hover {
              background-color: $theme-light-menu-hover-color;
            }
          }
          .menu-level-two { // 二级菜单
            background-color: transparent;
            .level-two-item {
              &.active {
                .level-two-tit {
                  background: #f4faff;
                }            
              }
              .level-two-tit {
                background: none;
              }
            }
            .menu-level-three { // 三级菜单
              background-color:#eaf3fd;
              color: rgba(0,0,0,0.65);
              .level-three-item {
                background-color: #eaf3fd;                
                &:hover {
                  background-color: rgba(74,141,240,.2);
                  color: #333;
                }
              }
            }
          }
        }
      }   
    }    
  }
  &.menu-collapsed { // 左侧菜单折叠
    .layout-aside {
      width: $aside-width-collapsed;
      .menus-wrapper {
        .menu-level-one {
          padding-right: 0;
          &.opened {
            .menu-level-two {
              display: none;
            }
          }
          &.active {
            .menu-icon {
              background-color: #369afe;
            }
            .menu-level-two {
              .level-two-item {
                &.active {
                  .level-two-tit {
                    border-left-color: transparent;
                  }            
                }
              }
            }
          }
          &:hover {
            .menu-level-two {
              display: block;
            }
          }
          .menu-name { // 折叠状态下菜单名字和右箭头都隐藏起来
            display: none;
          }
          .menu-arrow {
            display: none;
          }
          .menu-level-two {
            position: absolute;
            left: 100%;
            top: 0;
            width: 192px;
          }
        }
      }
    }
    .layout-main {
      left: calc(#{$aside-width-collapsed} + 1px);
    }
  }
}

// 侧栏样式
.layout-aside {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  bottom: 0;
  width: $aside-width;  
  display: flex;
  flex-direction: column;
  box-shadow: 1px 0px 0px 0px rgba(0,0,0,0.05);
  .aside-header {
    .logo {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 15px 20px;
      user-select: none;
      img {
        width: 147px;
      }
    }
    .cur-selected-box {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 15px 20px;      
      .cur-selected-inner {
        width: 160px;
        height: 52px;
        background: #202b3f;
        border-radius: 2px;
        box-shadow: 1px 0px 0px 0px rgba(0,0,0,0.05);
        padding: 8px;
        display: flex;
        align-items: center;
        position: relative;
        cursor: pointer;
        .avatar {
          width: 36px;
          height: 36px;
          background-color: rgba(255, 255, 255, .5);
          border-radius: 2px;
          box-shadow: 1px 0px 0px 0px rgba(0,0,0,0.05); 
        }
        .cur-selected-info {
          margin: 0 4px 0 8px;
          display: flex;
          flex-direction: column;
          width: 90px;
          .info-top, .info-bottom {
            width: 100%;
            @include mix-ellipsis;
          }
          .info-bottom {
            font-size: 12px;
          }
          
        }
        .right-arrow {
          position: absolute;
          right: 0;
          top: 50%;
          width: 12px;
          height: 12px;
          transform: translateY(-50%);
          &:after {
            content: '';
            width: 0;
            height: 0;
            position: absolute;
            left: 0;
            top: 0;
            border-top: 6px solid transparent;
            border-left: 6px solid #fff;
            border-bottom: 6px solid transparent;
          }
        }
      }
    }   
  }
  // 菜单管理
  .menus-wrapper {
    height: 0;
    flex: 1;
    .menu-level-one {
      width: 100%;
      min-height: 54px;
      position: relative;
      cursor: pointer;
      &.opened {
        .menu-level-two { // 二级菜单
          display: block;
        }
        .menu-arrow {
          transform: rotateZ(180deg);
        }
      }      
      .menu-icon {
        position: absolute;        
        left: 0;
        top: 0;
        width: 38px;
        text-align: center;
        line-height: 54px;
      }
      .menu-arrow { // 右侧箭头
        position: absolute;        
        right: 12px;
        top: 0;
        line-height: 54px;
        .iconfont {
          font-size: 10px;
        }
      }
      .menu-name {
        height: 100%;
        line-height: 54px;
        padding: 0 0 0 38px;
        &:hover {
          background-color: $theme-dark-menu-hover-color;       
        }
      }
      .menu-level-two { // 二级菜单
        display: none;
        position: relative;
        background-color: #202b3f;
        .level-two-item {
          &.active {
            .level-two-tit {
              background: rgba(0,102,255,0.15);
              color: #369afe;
              border-left-color: #369afe;
            }            
          }
          &:hover {
            .menu-level-three {
              display: block;
            }
          }
          .level-two-tit {
            height: 40px;
            line-height: 40px;
            padding: 0 0 0 38px;
            box-sizing: border-box;
            // background: rgba(0,102,255,0.15);
            // color: #369afe;
            background: #202b3f;       
            border-left: 4px solid transparent;            
            &:hover {
              background: rgba(0, 102, 255, 0.15);
              color: #369afe;              
            }
          }
        }
        .menu-level-three { // 三级菜单
          position: absolute;
          display: none;
          transition: all 0.3s ease-in;
          left: 100%;
          top: 0;
          width: 180px;
          // padding: 4px 1px 4px 0;
          background-color: #202b3f;
          // background-color: rgba(74,141,240,.4);
          border-top-right-radius: 4px;
          border-bottom-right-radius: 4px;
          color: #fff;
          .level-three-item {
            height: 40px;
            line-height: 40px;
            padding-left: 18px;
            // background-color: #eaf3fd;
            &:first-child {
              border-top-right-radius: 4px;
            }
            &:last-child {
              border-bottom-right-radius: 4px;
            }
            &:hover {
              background-color: rgba(0, 102, 255, 0.15);
              color: #369afe;
            }
          }
        }
      }
    }    
  } 
}

// 主体样式
.layout-main {
  position: absolute;
  left: calc(#{$aside-width} + 1px);
  top: 0;
  right: 0;
  bottom: 0;
  // 框架头部
  .layout-header {
    height: 56px;
    padding: 0 24px;
    @include mix-flex-between;
    box-shadow: 0px -1px 0px 0px rgba(0,0,0,0.05) inset;
    &-left {
      .iconfont {
        cursor: pointer;
      }
    }
    &-right {
      @include mix-flex-between;

      .layout-header-icons {
        @include mix-flex-between;
        
        > span {
          cursor: pointer;
          font-size: 22px;
          margin: 0 10px;
          &.icon-set {
            font-size: 18px;
            margin-right: 20px;
          }
        }
      }
      // 登录用户头像
      .login-user {
        width: 30px;
        height: 30px;
        line-height: 30px;
        color: #fff;
        background: #369afe;
        border-radius: 50%;
        text-align: center;
        cursor: pointer;
      }
    }
  }

  .nav-box {
    padding: 0 24px;    
    .nav-inner {
      height: 48px;
      background-color: #fff;
      @include mix-flex-between;
    }    
    background: $main-bg-color;
  }
  
  &-content {
    position: absolute;
    left: 0;
    top: 104px;
    right: 0;
    bottom: 0;
    padding: 0 24px 24px;
    background: $main-bg-color;
    overflow-y: auto;
    .main-content-inner {
      width: 100%;
      height: 100%;
      // height: 1000px;
      background-color: #fff;      
    }
  }
}